package com.yox.testClient;

import com.yox.rpc.api.ByeService;
import com.yox.rpc.api.HelloObject;
import com.yox.rpc.api.HelloService;
import com.yox.rpc.transport.RpcClientProxy;
import com.yox.rpc.transport.socket.client.SocketClient;

public class SocketTestClient {
    public static void main(String[] args) {
        // 创建Socket客户端，可以连接Socket服务器和Netty服务器,参数是序列化器(默认是Kryo)
        SocketClient client = new SocketClient();

        // 生成代理对象
        RpcClientProxy proxy = new RpcClientProxy(client);
        HelloService helloService = proxy.getProxy(HelloService.class);

        //创建一个调用对象
        HelloObject helloObject = new HelloObject(23, "Hello Rpc!");
        // 使用代理对象调用 hello方法
        String res = helloService.hello(helloObject);
        System.out.println(res);
        ByeService byeService = proxy.getProxy(ByeService.class);
        System.out.println(byeService.bye("Socket"));
    }
}
